<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 *
 */
$styleSheet = "orange";
$pageNO = isset($_POST['pageNO'])?$_POST['pageNO']:'1';

	function getNextSortOrder($curSortOrder) {
		switch ($curSortOrder) {
			case 'null' :
				return 'ASC';
				break;
			case 'ASC' :
				return 'DESC';
				break;
			case 'DESC'	:
				return 'ASC';
				break;
		}
	}
	
	    $GLOBALS['lang_Common_SortAscending'] = $lang_Common_SortAscending;
    $GLOBALS['lang_Common_SortDescending'] = $lang_Common_SortDescending;

	function nextSortOrderInWords($sortOrder) {
        return $sortOrder == 'ASC' ? $GLOBALS['lang_Common_SortDescending'] : $GLOBALS['lang_Common_SortAscending'];
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../themes/<?php echo $styleSheet; ?>/css/style.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 6]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE6_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if IE]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<script type="text/javascript" src="../../themes/<?php echo $styleSheet;?>/scripts/style.js"></script>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../../scripts/octopus.js"></script>
<script type="text/javascript">

	function nextPage() {
		i=document.standardView.pageNO.value;
		i++;
		document.standardView.pageNO.value=i;
		document.standardView.submit();
	}

	function prevPage() {
		var i=document.standardView.pageNO.value;
		i--;
		document.standardView.pageNO.value=i;
		document.standardView.submit();
	}

	function chgPage(pNO) {
		document.standardView.pageNO.value=pNO;
		document.standardView.submit();
	}
	
	function returnDelete() {
		$check = 0;
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if ((elements[i].type == 'checkbox') && (elements[i].checked == true)){
					$check = 1;
				}
			}
		}

		if ( $check == 1 ){
			document.standardView.delState.value = 'DeleteMode';
			document.standardView.pageNO.value=1;
			document.standardView.submit();
		}else{
			alert("<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>");
		}
	}


	function returnSearch() {

		document.standardView.captureState.value = 'SearchMode';
		document.standardView.pageNO.value=1;
		document.standardView.submit();
	}

	function doHandleAll()
	{
		with (document.standardView) {
			if(elements['allCheck'].checked == false){
				doUnCheckAll();
			}
			else if(elements['allCheck'].checked == true){
				doCheckAll();
			}
		}
	}

	function doCheckAll() {
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox') {
					elements[i].checked = true;
				}
			}
		}
	}

	function doUnCheckAll()
	{
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox') {
					elements[i].checked = false;
				}
			}
		}
	}
	
	/**
	 * If at least one day is unchecked, main check box would be unchecked
	 */

	function unCheckMain() {
		noOfCheckboxes = 0;
		noOfCheckedCheckboxes = 0;

		with (document.getElementById('standardView')) {
			for (i = 0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox' && elements[i].name != 'allCheck') {
					noOfCheckboxes++;
					if (elements[i].checked == true) {
						noOfCheckedCheckboxes++;
					}

				}
			}
		}

		document.getElementById('allCheck').checked = (noOfCheckboxes == noOfCheckedCheckboxes);
	}

	function clear_form() {
		document.standardView.loc_code.options[0].selected=true;
		document.standardView.loc_name.value='';
	}
</script>
<div class="outerbox">
	<form name="standardView" id="standardView" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?adcode=report&action=<?php echo $records['action'];?>&sortField=<?php echo $this->getArr['sortField']; ?>&amp;sortOrder<?php echo $this->getArr['sortField']; ?>=<?php echo $this->getArr['sortOrder'.$this->getArr['sortField']]?>">

		<div class="mainHeading"><h2><?php echo $records['Title'];?> - 报表</h2></div>
		<input type="hidden" name="captureState" value="<?php echo isset($this->postArr['captureState'])?$this->postArr['captureState']:''?>" />
		<input type="hidden" name="pageNO" value="<?php echo $pageNO;?>" />
		<input type="hidden" name="empID" value="" />


		<div class="searchbox">
			
			<?php if($records['action'] == "Month") { ?>
			<label for="loc_code">选择年份：</label>
			<select name="Year" id="Year">
				<?php
					 for ($i=@date("Y");$i>=2000;$i--) {
						if (isset($_REQUEST['Year']) && $_REQUEST['Year']==$i) {
						   echo "<option selected value='" . $i ."'>".$i ."年</option>";
						} else {
						   echo "<option value='" . $i ."'>".$i ."年</option>";
						}
					}
				?>
			</select>
			<label for="loc_code">选择月份：</label>
			<select name="Month" id="Month">
				<?php
					 for ($i=1;$i<=12;$i++) {
						if (isset($_REQUEST['Month']) && $_REQUEST['Month']==$i) {
						   echo "<option selected value='" . $i ."'>".$i ."月</option>";
						} else {
						   echo "<option value='" . $i ."'>".$i ."月</option>";
						}
					}
				?>
			</select>
			<?php } ?>
			
			<?php if($records['action'] == "Quarter") { ?>
			<label for="loc_code">选择年份：</label>
			<select name="Year" id="Year">
				<?php
					 for ($i=@date("Y");$i>=2000;$i--) {
						if (isset($_REQUEST['Year']) && $_REQUEST['Year']==$i) {
						   echo "<option selected value='" . $i ."'>".$i ."年</option>";
						} else {
						   echo "<option value='" . $i ."'>".$i ."年</option>";
						}
					}
				?>
			</select>
			<label for="loc_code">选择季度：</label>
			<select name="Jidu" id="Jidu">
				<?php
					 for ($i=1;$i<=4;$i++) {
						if (isset($_REQUEST['Jidu']) && $_REQUEST['Jidu']==$i) {
						   echo "<option selected value='" . $i ."'>第".$i ."季度</option>";
						} else {
						   echo "<option value='" . $i ."'>第".$i ."季度</option>";
						}
					}
				?>
			</select>
			<?php } ?>

			<?php if($records['action'] == "Year") { ?>
			<label for="loc_code">选择年份：</label>
			<select name="Year" id="Year">
				<?php
					 for ($i=@date("Y");$i>=2000;$i--) {
						if (isset($_REQUEST['Year']) && $_REQUEST['Year']==$i) {
						   echo "<option selected value='" . $i ."'>".$i ."年</option>";
						} else {
						   echo "<option value='" . $i ."'>".$i ."年</option>";
						}
					}
				?>
			</select>
			<?php } ?>
			<?php if($_SESSION['isAdmin'] == "Yes") { ?>
			<label for="loc_code">选择条件：</label>
			<select name="loc_code" id="loc_code">
				<?php
					 $optionCount = count($searchlist);
					 foreach ($searchlist as $key => $val) {
						if (isset($_POST['loc_code']) && $_POST['loc_code']==$key) {
						   echo "<option selected value='" . $key ."'>".$val ."</option>";
						} else {
						   echo "<option value='" . $key ."'>".$val ."</option>";
						}
					}
				?>
			</select>
			<label for="loc_name"><?php echo $description?></label>
			<input type="text" size="20" name="loc_name" id="loc_name" value="<?php echo isset($_POST['loc_name'])? stripslashes($_POST['loc_name']):''?>" />
			<?php } ?>
			<input type="button" class="plainbtn" onclick="returnSearch();"
				onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
				value="<?php echo $lang_Common_Search;?>" />
			<input type="button" class="plainbtn" onclick="clear_form();"
				onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
				 value="<?php echo $lang_Common_Reset;?>" />
			<br class="clear"/>
		</div>

			<div class="actionbar">
				<div class="actionbuttons">
					<input type="button" class="plainbtn"
					<?php echo ($locRights['add']) ? 'onclick="returnAdd();"' : 'style=visibility:hidden;'; ?>
						onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
						value="<?php echo $lang_Common_Add;?>" />


						<input type="button" class="plainbtn"
						<?php echo ($locRights['delete']) ? 'onclick="returnDelete();"' : 'style=visibility:hidden;'; ?>
							onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
							value="<?php echo $lang_Common_Delete;?>" />


				</div>
				<div class="noresultsbar"><?php echo (empty($emplist)) ? $norecorddisplay : '';?></div>
				<div class="pagingbar">
				<?php
					$commonFunc = new CommonFunctions();
					$pageStr = $commonFunc->printPageLinks($records['Allcount'], $pageNO);
	
					$pageStr = preg_replace(array('/#first/', '/#previous/', '/#next/', '/#last/'), array($lang_empview_first, $lang_empview_previous, $lang_empview_next, $lang_empview_last), $pageStr);

					echo $pageStr;

					for ($j = 0; $j < 11; $j++) {
						if (!isset($this->getArr['sortOrder'.$j])) {
							$this->getArr['sortOrder'.$j] = 'null';
						}
					}
				?>
				</div>
			<br class="clear" />
			</div>
			<br class="clear" />
				<table cellspacing="0" cellpadding="0" class="data-table">
					<thead>
					<tr>
						<!--<td width="50">
	
							<input type="checkbox" name="allCheck" id="allCheck" class="checkbox" style="margin-left:1px"
								onclick="doHandleAll()" />
				
						</td>-->
						<td scope="col">生成报表</td>
						<td scope="col">日期</td>
						<td scope="col">员工编号</td>
						<td scope="col">员工名字</td>
						<td scope="col">部门</td>
						<td scope="col">在职状态</td>
						<td scope="col">安排工作小时</td>
						<td scope="col">总工作小时</td>
						<td scope="col">实际夜班天数</td>
						<!--<td scope="col">平时加班次数</td>-->
						<td scope="col">平时加班小时</td>
						<!--<td scope="col">周末加班次数</td>-->
						<td scope="col">周末加班小时</td>
						<!--<td scope="col">节假日加班次数</td>-->
						<td scope="col">节假日加班小时</td>
						<td scope="col">迟到次数</td>
						<td scope="col">早退次数</td>
						<td scope="col">旷工次数</td>
						<!--<td scope="col">事假次数</td>-->
						<td scope="col">事假小时</td>
						<!--<td scope="col">病假次数</td>-->
						<td scope="col">病假小时</td>
						<!--<td scope="col">年假次数</td>-->
						<td scope="col">年假小时</td>
						<!--<td scope="col">婚假次数</td>-->
						<td scope="col">婚假小时</td>
						<!--<td scope="col">丧假次数</td>-->
						<td scope="col">丧假小时</td>
						<!--<td scope="col">产假次数</td>-->
						<td scope="col">产假小时</td>
						<!--<td scope="col">临换次数</td>-->
						<td scope="col">临换小时</td>
						<!--<td scope="col">外勤次数</td>-->
						<td scope="col">外勤小时</td>
					</tr>
					</thead>

					<tbody>
					<?php
							$list = $records['list'];
							
							for ($j=0; $j<count($list);$j++) {
								$subDivision = "-";
								$compStructObj = new CompStruct();
								$compStructObj->buildAllWorkStations();
								if (isset($list[$j]['work_station']) && !empty($list[$j]['work_station'])) {
									$subDivision = $compStructObj->fetchHierarchString($list[$j]['work_station']);
								}

					?>
								<tr class="<?php echo $cssClass;?>">

									<td scope="col">
									<?php if($list[$j]['IsRecord'] == 0) { ?>
									<a href="<?php echo $_SERVER['PHP_SELF']?>?adcode=report&action=Create&crtype=<?php echo $list[$j]['crtype']?>&cryear=<?php echo $list[$j]['cryear']?>&crotherd=<?php echo $list[$j]['crotherd']?>&emp_number=<?php echo $list[$j]['emp_number']?>">系统生成</a>
									<?php } else { ?>
									<font color="red">审核确认</font>
									<?php } ?>
									</td>
									<td scope="col"><?php echo $list[$j]['riqi']?></td>
									<td scope="col"><?php echo $list[$j]['employee_id']?></td>
								
									<td scope="col"><?php echo $list[$j]['emp_firstname'].$list[$j]['emp_lastname']?></td>
									<td scope="col"><?php echo $subDivision?></td>
									<td scope="col"><?php echo $list[$j]['isOnWork']?></td>
									<td scope="col"><?php echo $list[$j]['NeedWorkHours']?></td>
									<td scope="col"><?php echo $list[$j]['WorkHours']?></td>

									<td scope="col"><?php echo $list[$j]['yeban']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['psjiaban']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['psjiaban']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['weekjiaban']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['weekjiaban']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['holidayjiaban']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['holidayjiaban']['time']?></td>
									
									<td scope="col"><?php echo intval($list[$j]['later'])?></td>
									<td scope="col"><?php echo intval($list[$j]['ZaoTui'])?></td>
									<td scope="col"><?php echo intval($list[$j]['kuangGong'])?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['shijia']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['shijia']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['bingjia']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['bingjia']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['nianjia']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['nianjia']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['hunjia']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['hunjia']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['sangjia']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['sangjia']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['chanjia']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['chanjia']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['linhuan']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['linhuan']['time']?></td>
									
									<!--<td scope="col"><?php echo intval($list[$j]['waiqin']['num'])?></td>-->
									<td scope="col"><?php echo $list[$j]['waiqin']['time']?></td>

	
							</tr>
						<?php } ?>
					</tbody>
				</table>
	</form>
</div>
<script type="text/javascript">
//<![CDATA[
    if (document.getElementById && document.createElement) {
        roundBorder('outerbox');
    }
//]]>
</script>
